﻿using SelfMadeMillionaire.Core.Entities;
using SelfMadeMillionaire.Core.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SelfMadeMillionaire.DAL.Repositories
{
	public class NewsRepository : Repository<News>, INewsRepository
	{
		public NewsRepository(IUnitOfWork uow)
			: base(uow)
		{
		}

		public override News Update(News entity)
		{
			var dbEntity = Get(entity.ID);

			dbEntity.Title = entity.Title;
            dbEntity.Date = entity.Date;
            dbEntity.ProductType = entity.ProductType;
            dbEntity.Tooltip = entity.Tooltip;
            dbEntity.ExternalUrl = entity.ExternalUrl;
            dbEntity.MinAccessLevel = entity.MinAccessLevel;
			
			Commit();

			return dbEntity;
		}

		public IEnumerable<IssueType> GetIssueTypes()
		{
			return _uow.GetDbSet<IssueType>();
		}
	}
}
